package org.deadline.service.user;

import java.util.List;
import org.deadline.model.user.UserGroupMember;
import org.deadline.repository.user.UserGroupMemberRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class UserGroupMemberServiceImpl implements UserGroupMemberService {

	@Autowired
    UserGroupMemberRepository userGroupMemberRepository;

	public long countAllUserGroupMembers() {
        return userGroupMemberRepository.count();
    }

	public void deleteUserGroupMember(UserGroupMember userGroupMember) {
        userGroupMemberRepository.delete(userGroupMember);
    }

	public UserGroupMember findUserGroupMember(Long id) {
        return userGroupMemberRepository.findOne(id);
    }

	public List<UserGroupMember> findAllUserGroupMembers() {
        return userGroupMemberRepository.findAll();
    }

	public List<UserGroupMember> findUserGroupMemberEntries(int firstResult, int maxResults) {
        return userGroupMemberRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveUserGroupMember(UserGroupMember userGroupMember) {
        userGroupMemberRepository.save(userGroupMember);
    }

	public UserGroupMember updateUserGroupMember(UserGroupMember userGroupMember) {
        return userGroupMemberRepository.save(userGroupMember);
    }
}
